<?php
/*
 * Author :pandiam
 */
session_start();
require_once ('../Frameworks/Objects/category.php');

if (!isset($_SESSION['uid']) || $_SESSION['uid'] == -1) {
    UI_registerError('msg_warning', "You are not logged in.");
    header('Location: login.php');
}

$attrs = "";

if (isset($_SESSION['error']))
{
    $comp = split("-", $_SESSION['error']);
    for ($i = 0; $i < count($comp); $i++)
    {
        if ($i == 0)
            $attrs = $comp[$i];
        else
            $attrs = $attrs . "," . $comp[$i];
    }
    unset($_SESSION['error']);
}
?>
<link type="text/css" href="css/jquery-ui.custom.css" rel="stylesheet" />
<link type="text/css" href="css/formalize.css" rel="stylesheet" />
<link type="text/css" href="css/text.css" rel="stylesheet" />
<script type="text/javascript" src="js/libs/jquery.js"></script>
<script type="text/javascript" src="js/libs/jquery-ui.js"></script>
<script type="text/javascript" src="js/libs/jquery.formalize.min.js"></script>
<link type="text/css" href="css/reset.css" rel="stylesheet" />

<form name="createCategory" action="createCategoryDo.php" method="post">
<input type="hidden" name="data" />
<div id="complCreate">
    <div id="createCat">
       <h3  align="center" style="margin-bottom:10px">Category Info</h3>
       <table style="margin-bottom:10px;">
            <tr>
                <td align="right">Category name<font color="red">*</font> :</td>
                <td><input style="height:20px" type="text" name="catname" id="catname" maxlength="30" size="30"/></td>
            </tr>
            <tr>
                <td align="right">Category type<font color="red">*</font> :</td>
                <td align="left">
                    <select id="catType" name="catType">
                       <option value="0">Public</option>
                       <option value="1">Private</option>
                    </select>
                </td>
            </tr>
        </table>
       <div id="insertAttribute">
            <h3 align="center" style="margin-top:20px">Insert Attribute</h3>
            <table>
                <tr>
                    <td align="right">Attribute name<font color="red">*</font> :</td>
                    <td><input style="height:20px" type="text" id="attrname" maxlength="30" size="30"/></td>
                </tr>
                <tr>
                    <td align="right">Attribute type<font color="red">*</font> :</td>
                    <td align="center">
                        <input type="radio" name="type" id="meausure" value="measurable" onchange="javascript:toggle(1)" checked="checked" />Measurable
                        <input type="radio" name="type" id="unmeausure" value="unmeasurable" onchange="javascript:toggle(2)" />Un-Measurable
                    </td>

                </tr>
                <tr align="center">
                      <td></td><td><input type="radio" name="type" id="uncomparable" value="uncomparable" onchange="javascript:toggle(2)"/>Un-Comparable</td>
                </tr>
            <tr  id="hide_this" style="visibility:visible">
                <td align="right">Best Value<font color="red">*</font> :</td>
                    <td>
                        <select id="best" onchange="javascript:toggleSelect()">
                        <option value="min">Min</option>
                        <option value="max">Max</option>
                        <option value="close_to">Close To</option>
                        </select>
                        <input style="visibility:hidden; height:20px" type="text" id="close_to" name="close_to_val" maxlength="30" size="10"/>
                    </td>
            </tr>
            </table>
        </div>
        <a style="margin:0 0 0 40%" id="add_new_attr" href="javascript:keepAttribute()">Add new</a><br/><br/>
        <input style="margin:0 0 0 39%" class="button" type="button" onClick="javascript:passData()" value="Submit" />
    </div>
    <div id="attrListCreate">
        <h3 style=" margin:0 0 10px 0">Attribute List</h3>
        <div id="attrCat" style="max-height:400px;">
        </div>
    </div>

</div>
</form>

<script type="text/javascript" src="js/libs/jquery.js"></script>
<script type="text/javascript" src="js/createCategoryLib.js"></script>

<?php
if ($attrs != "")
{
    echo "<script type=\"text/javascript\">";
    echo "convert( \"" . $attrs . "\");";
    echo "changeContent(\"delete\");";
    echo "</script>";
}
?>